package com.ruoyi.system.service.impl;

import com.ruoyi.common.redis.service.IdGeneratorService;
import com.ruoyi.system.api.domain.SysOperatorLog;
import com.ruoyi.system.mapper.SysOperatorLogMapper;
import com.ruoyi.system.service.ISysOperatorLogService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 操作日志 服务层处理
 *
 * @author RuoYi
 */
@Service
@RequiredArgsConstructor
public class SysOperatorLogServiceImpl implements ISysOperatorLogService {

    private final SysOperatorLogMapper operatorLogMapper;

    private final IdGeneratorService idGeneratorService;

    /**
     * 新增操作日志
     *
     * @param operatorLog 操作日志对象
     * @return 结果
     */
    public int insertOperatorLog(SysOperatorLog operatorLog) {
        String operId = idGeneratorService.generateId("SOL");
        operatorLog.setOperId(operId);
        return operatorLogMapper.insertOperatorLog(operatorLog);
    }

    /**
     * 查询系统操作日志集合
     *
     * @param operLog 操作日志对象
     * @return 操作日志集合
     */
    @Override
    public List<SysOperatorLog> selectOperatorLogList(SysOperatorLog operLog) {
        return operatorLogMapper.selectOperatorLogList(operLog);
    }

    /**
     * 批量删除系统操作日志
     *
     * @param operIds 需要删除的操作日志ID
     * @return 结果
     */
    @Override
    public int deleteOperatorLogByIds(String[] operIds) {
        return operatorLogMapper.deleteOperatorLogByIds(operIds);
    }

    /**
     * 查询操作日志详细
     *
     * @param operId 操作ID
     * @return 操作日志对象
     */
    @Override
    public SysOperatorLog selectOperatorLogById(String operId) {
        return operatorLogMapper.selectOperatorLogById(operId);
    }

    /**
     * 清空操作日志
     */
    @Override
    public void cleanOperatorLog() {
        operatorLogMapper.cleanOperatorLog();
    }
}
